package liuch.JMS;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;

import javax.jms.*;

/**
 * @author 17101651
 * @ClassName SpringJMSActiveMQTest
 * @Description 采用jmsTempalte配置jms连接工厂
 * @data 2018年08月18日
 */
public class SpringJMSActiveMQSenderTest {
    public static void main(String[] args) {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("/conf/spring/jms/beanFactoryTest.xml");

        JmsTemplateUtil.setApplicationContext(applicationContext);
        Destination destination = (Queue) applicationContext.getBean("queue");
        JmsTemplateUtil.sendMsg(destination, new Object());

       /* JmsTemplate jmsTemplate = (JmsTemplate) applicationContext.getBean("jmsTemplate");
        Queue queue = (Queue) applicationContext.getBean("queue");

        jmsTemplate.send(queue, new MessageCreator() {
            @Override
            public Message createMessage(Session session) throws JMSException {
                return session.createTextMessage("spring-jms");
            }
        });*/
    }
}
